package com.ruoyi.purchase.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Objects;

/**
 * 采购计划对象 purchase_plan
 *
 * @author kevinness
 * @date 2024-12-29
 */
public class PurchasePlan extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 采购计划编号 */
    @Excel(name = "采购计划编号")
    private String planNo;

    /** 周期编号 */
    private String cycleNo;

    /** 货品类别编码 */
    private String code;

    /** 货品名称 */
    @Excel(name = "货品名称")
    private String rawProductName;

    /** 货品件数 */
    @Excel(name = "货品数量")
    private Double quantity;

    /** 已购数量 */
    @Excel(name = "已购数量")
    private Double purchaseQuantity;

    /** 采购数量单位 */
    private String quantityUnit;

    /** 预算 */
    private Double budget;

    /** 预期单价 */
    private Double unitPrice;

    /** 货币类型 */
    private String currencyType;

    /** 货币单位 */
    private String currencyUnit;

    /** 需求日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "需求日期", width = 30, dateFormat = "yyyy-MM-dd")
    private String demandDate;

    /** 预期交货时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "预期交货时间", width = 30, dateFormat = "yyyy-MM-dd")
    private String expectedDeliveryTime;

    /** 计划生成时间 */
    private String createdTime;

    /** 修改日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "修改日期", width = 30, dateFormat = "yyyy-MM-dd")
    private String modifiedDate;

    /** 修改人 */
    private String modifiedBy;

    /** 计划状态 */
    @Excel(name = "计划状态")
    private String planStatus;

    /** 购买状态 */
    @Excel(name = "计划状态")
    private String purchaseStatus;

    /** 备注 */
    @Excel(name = "备注")
    private String remarks;

    public PurchasePlan(){

    }

    public PurchasePlan(String planNo, String cycleNo, String code, String rawProductName, Double quantity, Double budget, Double unitPrice, String demandDate, String expectedDeliveryTime, String createdTime, String modifiedDate, String modifiedBy, String remarks){
        this.planNo = planNo;
        this.cycleNo = cycleNo;
        this.code = code;
        this.rawProductName = rawProductName;
        this.quantity = quantity;
        this.budget = budget;
        this.unitPrice = unitPrice;
        this.demandDate = demandDate;
        this.expectedDeliveryTime = expectedDeliveryTime;
        this.createdTime = createdTime;
        this.modifiedDate = modifiedDate;
        this.modifiedBy = modifiedBy;
        this.remarks = remarks;
    }

    public PurchasePlan(String rawProductName) {
        this.rawProductName = rawProductName;
    }

    public void setPlanNo(String planNo)
    {
        this.planNo = planNo;
    }

    public String getPlanNo()
    {
        return planNo;
    }
    public String getCycleNo() {
        return cycleNo;
    }

    public void setCycleNo(String cycleNo) {
        this.cycleNo = cycleNo;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setRawProductName(String rawProductName)
    {
        this.rawProductName = rawProductName;
    }

    public String getRawProductName()
    {
        return rawProductName;
    }
    public void setQuantity(Double quantity)
    {
        this.quantity = quantity;
    }

    public Double getPurchaseQuantity() {
        return purchaseQuantity;
    }
    public void setPurchaseQuantity(Double purchaseQuantity) {
        this.purchaseQuantity = purchaseQuantity;
    }

    public Double getQuantity()
    {
        return quantity;
    }

    public String getQuantityUnit() {
        return quantityUnit;
    }

    public void setQuantityUnit(String quantityUnit) {
        this.quantityUnit = quantityUnit;
    }

    public Double getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(Double unitPrice) {
        this.unitPrice = unitPrice;
    }

    public void setBudget(Double budget)
    {
        this.budget = budget;
    }

    public Double getBudget()
    {
        return budget;
    }
    public void setCurrencyType(String currencyType)
    {
        this.currencyType = currencyType;
    }

    public String getCurrencyType()
    {
        return currencyType;
    }
    public void setCurrencyUnit(String currencyUnit)
    {
        this.currencyUnit = currencyUnit;
    }

    public String getCurrencyUnit()
    {
        return currencyUnit;
    }
    public void setDemandDate(String demandDate)
    {
        this.demandDate = demandDate;
    }

    public String getDemandDate()
    {
        return demandDate;
    }
    public void setExpectedDeliveryTime(String expectedDeliveryTime) {
        this.expectedDeliveryTime = expectedDeliveryTime;
    }

    public String getExpectedDeliveryTime()
    {
        return expectedDeliveryTime;
    }
    public void setCreatedTime(String createdTime)
    {
        this.createdTime = createdTime;
    }

    public String getCreatedTime()
    {
        return createdTime;
    }
    public void setModifiedDate(String modifiedDate)
    {
        this.modifiedDate = modifiedDate;
    }

    public String getModifiedDate()
    {
        return modifiedDate;
    }
    public void setModifiedBy(String modifiedBy)
    {
        this.modifiedBy = modifiedBy;
    }

    public String getModifiedBy()
    {
        return modifiedBy;
    }
    public void setPlanStatus(String planStatus)
    {
        this.planStatus = planStatus;
    }

    public String getPlanStatus()
    {
        return planStatus;
    }
    public void setRemarks(String remarks)
    {
        this.remarks = remarks;
    }

    public String getRemarks()
    {
        return remarks;
    }
    public String getPurchaseStatus() {
        return purchaseStatus;
    }

    public void setPurchaseStatus(String purchaseStatus) {
        this.purchaseStatus = purchaseStatus;
    }

    public void setPurchaseStatusByPurchaseQuantity(){
        if(this.getPurchaseQuantity() <= 0.0){
            this.setPurchaseQuantity(0.0);
            this.setPurchaseStatus("未开始");
        }
        else if(this.getPurchaseQuantity() > 0.0
                && this.getPurchaseQuantity() < this.getQuantity()){
            this.setPurchaseStatus("部分完成");
        }
        else if(Objects.equals(this.getPurchaseQuantity(), this.getQuantity())){
            this.setPurchaseStatus("全部完成");
        }
        else{
            this.setPurchaseStatus("超额完成");
        }
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("planNo", getPlanNo())
                .append("cycleNo", getCycleNo())
                .append("code", getCode())
                .append("rawProductName", getRawProductName())
                .append("quantity", getQuantity())
                .append("purchaseQuantity", getPurchaseQuantity())
                .append("quantityUnit", getQuantityUnit())
                .append("budget", getBudget())
                .append("unitPrice", getUnitPrice())
                .append("currencyType", getCurrencyType())
                .append("currencyUnit", getCurrencyUnit())
                .append("demandDate", getDemandDate())
                .append("expectedDeliveryTime", getExpectedDeliveryTime())
                .append("createdTime", getCreatedTime())
                .append("modifiedDate", getModifiedDate())
                .append("modifiedBy", getModifiedBy())
                .append("planStatus", getPlanStatus())
                .append("purchaseStatus", getPurchaseStatus())
                .append("remarks", getRemarks())
                .toString();
    }
}
